﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "NdbObjectSchematic.h"
#include "IExternalObject.h"
#include "ElementCreationOptions.h"
#include "RegenDataSchema.h"
#include "DBUtils.h"
#include "TaggingWall.h"
#include "TransferOwnership.h"


namespace gcmp
{
    class IDocument;
    class IElement;
    class ElementId;
    class Vector3d;
    class IGraphicsElementShape;
}

namespace Sample
{
    class TAGGINGWALL_EXPORT WallTag : public gcmp::NdbObjectSchematic, public gcmp::IExternalObject
    {
    private:
        DBOBJECT_DATA_BEGIN(Sample, WallTag, gcmp::NdbObjectSchematic, CC43B213 - C8B7 - 466C - BF4E - 61AB5F3D3D38, TaggingWall)
            DATA_TRANSIENT(gcmp::IElement*, OwnerElement)
            DATA(std::wstring, Name)
            DATA_REGEN(gcmp::Vector3d, ReferenceLineDir)
            DATA(gcmp::ElementId, WallId)
            DBOBJECT_DATA_END
    public:
        virtual ~WallTag() {};
        gcmp::IDocument* GetDocument() const;
        gcmp::ElementId GetOwnerElementId() const;
    public:
        std::wstring GetName() const;
        void SetName(const std::wstring& szName);
        gcmp::Vector3d GetReferenceLineDir() const { return GetReferenceLineDir__(); };
        void SetReferenceLineDir(const gcmp::Vector3d& pt) { SetReferenceLineDir__(pt); };
        gcmp::Vector3d GetReferenceLineStartPoint() const;
        virtual gcmp::ElementId GetWallId() const;
        virtual bool SetWallId(const gcmp::ElementId& wallId);
        gcmp::OwnerPtr<gcmp::IGraphicsElementShape> CreateGraphicsElementShape();

    public:  //重载IExternalObject
        virtual bool SetOwnerElement(gcmp::IElement* pOwnerElement) override;
        virtual const gcmp::IElement* GetOwnerElement() const override;
        virtual gcmp::IElement* GetOwnerElement() override;
        virtual void UpdateForWeakParentDeletion(const std::set<gcmp::ElementId>& deletedElementIds) override;
        virtual void ReportParents(gcmp::IElementParentReporter& elementParentReporter) const override;
        virtual bool FinishEditing() override;

    public:
        static WallTag* Create(gcmp::IDocument* pDoc, gcmp::ElementCreationOptions eco = gcmp::ElementCreationOptions::Normal);
        static  WallTag* Create(gcmp::IDocument* pDoc, const gcmp::Vector3d& referenceLineDir, gcmp::ElementId wallId, gcmp::ElementCreationOptions eco = gcmp::ElementCreationOptions::Normal);

        //夹点功能依赖
        static gcmp::UniIdentity GetImplementationUid();
        NDB_TOPPARENT_NULL;
    };
}